﻿
@using hc.epm.ViewModel;
@using hc.epm.Common;
@using hc.Plat.Common.Extend;
@using hc.epm.DataModel.Business;
@model CompletionAcceptanceView
@{
    ViewBag.Title = "查看竣工验收-项目信息页";
    Epm_Project item = ViewBag.project;

    List<CompletionAcceptanceItemView> itemList = ViewBag.CompletionAcceptanceItemList;
    var type = 0;
    var listQuestion = itemList.Where(p => p.Type == "Epm_Question" && !string.IsNullOrEmpty(p.Id)).ToList();
    if (listQuestion.Count > 0)
    {
        type = 1;
    }
}
<style>
    .ic_fail {
        width: 18px;
    }
</style>
@if (Model == null)
{
    <div class="contentData">
        <div class="tab">
            该数据已删除或者不存在！
        </div>
    </div>
}
else {
<div class="contentData">
    <div class="tab viewTab">
        <div class="long-text">
            <label>&nbsp;项目名称&nbsp;:</label>
            <input type="text" value="@item.Name" disabled />
        </div>
        <div class="long-text">
            <label>&nbsp;项目主体&nbsp;:</label>
            <input type="text" value="@item.ProjectSubjectName" disabled />
        </div>
        <div class="long-text">
            <label>&nbsp;项目类型&nbsp;:</label>
            <input type="text" value="@item.SubjectName" disabled />
        </div>
        <div class="long-text">
            <label>&nbsp;开始时间&nbsp;:</label>
            <input type="text" disabled value="@(item.PlanWorkStartTime == null ? "" : Convert.ToDateTime(item.PlanWorkStartTime).ToString("yyyy-MM-dd"))" />
        </div>
        <div class="long-text">
            <label>&nbsp;结束时间&nbsp;:</label>
            <input type="text" disabled value="@(item.PlanWorkEndTime == null ? "" : Convert.ToDateTime(item.PlanWorkEndTime).ToString("yyyy-MM-dd"))" />
        </div>
        <div class="long-text">
            <label>&nbsp;项目负责人&nbsp;:</label>
            <input type="text" disabled value="@item.ContactUserName" />
        </div>
        <div class="long-text">
            <label>&nbsp;负责人电话&nbsp;:</label>
            <input type="text" disabled value="@item.ContactPhone" />
        </div>
        <div class="long-text">
            <label>&nbsp;项目地址&nbsp;:</label>
            <input type="text" disabled value="@item.Address" />
        </div>
        <div class="intro">
            <div><label>&nbsp;项目简介&nbsp;:</label></div>
            <div>
                <textarea class="sub-description" disabled>@item.Description</textarea>
            </div>
        </div>
        <div class="button-group btn-center">
            <button type="button" class="btnNext">下一步</button>
        </div>
    </div>
    <div class="viewTab" style="display:none">
        @Html.Partial("_AcceptanceItem")
    </div>
    <div class="viewTab" style="display:none">
        <form id="mainForm">
            <div class="tab">
                <div class="long-text">
                    <label>&nbsp;项目名称&nbsp;:</label>
                    <input type="text" name="ProjectName" value="@item.Name" disabled />
                    <input type="hidden" name="ProjectId" id="ProjectId" value="@item.Id" />
                    <input type="hidden" name="Id" id="Id" value="@Model.CompletionAcceptance.Id" />
                    <i class="pic iconfont" width="20" height="30" style="cursor:pointer; left:596px;">&#xe76a;</i>
                </div>
                <div class="long-text">
                    <label>&nbsp;验收标题&nbsp;:</label>
                    <input type="text" value="@Model.CompletionAcceptance.Title" name="Title" disabled />
                </div>
                <div class="short-text">
                    <label>&nbsp;验收时间&nbsp;:</label>
                    <input type="text" id="RecTime" name="RecTime" onClick="WdatePicker({ el: 'RecTime' })" value="@(Model.CompletionAcceptance.RecTime == null ? "" : Convert.ToDateTime(Model.CompletionAcceptance.RecTime).ToString("yyyy-MM-dd"))" disabled>
                    <i onClick="WdatePicker({ el: 'RecTime' })" class="pic iconfont" width="20" height="30" style="cursor:pointer">&#xe7e2;</i>
                </div>
                <div class="intro">
                    <div><label>&nbsp;验收内容&nbsp;:</label></div>
                    <div>
                        <textarea class="sub-description" name="content" id="content" disabled>@Model.CompletionAcceptance.Content</textarea>
                    </div>
                </div>
                <div>
                    <label>&nbsp;验收类型&nbsp;:</label>
                    <input type="checkbox" name="AcceptanceResult" id="AcceptanceResult" value="80" />整改后通过
                </div>
                <div class="intro AcceptanceResult" style="display:none;">
                    <label>&nbsp;整改单位&nbsp;:</label>
                    <table class="datalist" style="word-break:break-all;word-wrap:break-word;width:79%;margin-left:2px;">
                        <thead>
                            <tr>
                                <th>整改单位</th>
                            </tr>
                        </thead>
                        <tbody>
                            @if (Model.CompletionRectifyCompanys != null && Model.CompletionRectifyCompanys.Count() > 0)
                            {
                                foreach (var list in Model.CompletionRectifyCompanys)
                                {
                                    <tr>
                                        <td>@list.CompanyName</td>
                                    </tr>
                                }
                            }
                        </tbody>
                    </table>
                </div>
                <div class="intro AcceptanceResult" style="display:none;">
                    <div><label>&nbsp;整改内容&nbsp;:</label></div>
                    <div>
                        <textarea class="sub-description" name="RectifContent" id="RectifContent" disabled>@Model.CompletionAcceptance.RectifContent</textarea>
                    </div>
                </div>
                <div class="long-text">
                    <label>&nbsp;验收单位&nbsp;:</label>
                    <input type="text" id="RecCompanyName" name="RecCompanyName" value="@Model.CompletionAcceptance.RecCompanyName" disabled />
                    <input type="hidden" id="RecCompanyId" name="RecCompanyId" value="@Model.CompletionAcceptance.RecCompanyId" />
                    <i class="pic iconfont" width="20" height="30" style="cursor:pointer; left:596px;">&#xe76a;</i>
                </div>
                <div class="long-text">
                    <label>&nbsp;验收人员&nbsp;:</label>
                    <input type="text" name="RecUserName" id="RecUserName" value="@Model.CompletionAcceptance.RecUserName" disabled />
                    <input type="hidden" id="RecUserId" name="RecUserId" value="@Model.CompletionAcceptance.RecUserId" />
                    <i class="pic iconfont" width="20" height="30" style="cursor:pointer; left:596px;">&#xe76a;</i>
                </div>
                <div class="upload" style="margin-bottom:0px;">
                    <div><label>&nbsp;验收单&nbsp;:</label></div>
                    @*<div class="btn-upload">
                        <input type="button" id="btnUploadFileYSD" name="YSD" style="position: relative; z-index: 1;" value="上传附件" />
                        <span style="vertical-align:bottom; margin-left:15px; color:#B7B7B7;"></span>
                    </div>*@
                </div>
                <div style="width:100%; margin-top:-30px;" id="fileListFile">
                    <ul class="fileShow" id="YSD"></ul>
                </div>

                <div class="upload" style="margin-bottom:0px;display:none;">
                    <div><label>&nbsp;竣工图&nbsp;:</label></div>
                    @*<div class="btn-upload">
                        <input type="button" id="btnUploadFileJGT" name="JGT" style="position: relative; z-index: 1;" value="上传附件" />
                        <span style="vertical-align:bottom; margin-left:15px; color:#B7B7B7;"></span>
                    </div>*@
                </div>
                <div style="width:100%; margin-top:-30px;" id="fileListFile">
                    <ul class="fileShow" id="JGT"></ul>
                </div>

                <div class="upload" style="margin-bottom:0px;display:none;">
                    <div><label style="width: 265px;margin-left: -147px;">&nbsp;审计金额（土建、包装、安装、加固）&nbsp;:</label></div>
                    @*<div class="btn-upload">
                        <input type="button" id="btnUploadFileSJJE" name="SJJE" style="position: relative; z-index: 1;" value="上传附件" />
                        <span style="vertical-align:bottom; margin-left:15px; color:#B7B7B7;"></span>
                    </div>*@
                </div>
                <div style="width:100%; margin-top:-30px;" id="fileListFile">
                    <ul class="fileShow" id="SJJE"></ul>
                </div>

                <div class="upload" style="margin-bottom:0px;display:none;">
                    <div><label style="width: 265px;margin-left: -147px;">&nbsp;外部申请材料上传定案表&nbsp;:</label></div>
                    @*<div class="btn-upload">
                        <input type="button" id="btnUploadFileWBSQD" name="WBSQD" style="position: relative; z-index: 1;" value="上传附件" />
                        <span style="vertical-align:bottom; margin-left:15px; color:#B7B7B7;"></span>
                    </div>*@
                </div>
                <div style="width:100%; margin-top:-30px;" id="fileListFile">
                    <ul class="fileShow" id="WBSQD"></ul>
                </div>
                <div class="button-group btn-center">
                    <button type="button" class="btnPrev">上一步</button>
                    <input type="hidden" name="State" id="State" />                  
                   @if (Model.CompletionAcceptance.State == int.Parse(ApprovalState.WaitAppr.GetValue().ToString()))
                   {
                        <button type="button" class="ApprSuccess checkright" data-module="CompletionAcceptance" data-right="Check">审核</button>
                        <button type="button" class="ApprFailure checkright" data-module="CompletionAcceptance" data-right="UnCheck">驳回</button>
                   }
                </div>
            </div>
        </form>
    </div>
    <input type="hidden" value="@type" id="Type" />
</div>
<script>
    var fileDataArray = [];
    var acceptanceResult = "@Model.CompletionAcceptance.AcceptanceResult";
    if (acceptanceResult == 80) {
        $("#AcceptanceResult").attr("checked", true);
        $(".AcceptanceResult").show();
    }
    layui.use(['layer', 'laydate', 'form', 'element', 'laypage'], function () {
        var layer = layui.layer, form = layui.form, element = layui.element, $ = layui.jquery, laypage = layui.laypage; laydate = layui.laydate
        //获取附件
       //获取图片附件
        $.post("/Files/GetFileList", { tableName: 'Epm_CompletionAcceptance', id: '@Model.CompletionAcceptance.Id' }, function (data) {
            if (data.Flag) {
                if (data.Data.length > 0) {
                    data.Data.forEach(function (item, index, arr) {
                        var obj = {};
                        obj.Name = item.Name;
                        obj.GuidId = item.GuidId;
                        obj.Size = item.Size;
                        obj.Group = item.Group;
                        obj.Url = item.Url;
                        obj.TableColumn = item.TableColumn;
                        obj.ImageType = item.ImageType;
                        fileDataArray.push(obj);
                        fileDataJson = JSON.stringify(fileDataArray);
                        $("#fileDataJsonFile").val(fileDataJson);

                        if (item.ImageType == null) {
                            var time = item.OperateTime;
                            var date = new Date(parseInt(time.slice(6)));
                            var result = date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate();

                            var tyep = item.Name.split(".");
                            var odiv = '<li id="' + item.GuidId + '">';
                            odiv += '<div class="downloadFile"><img src="' + getFileImg(item.Name) + '" style="width: 20px;height: 20px;cursor: pointer;" class="imgShow"/><a href="javascript:;" target="_blank">' + item.Name + '</a></div>';
                            odiv += '<div>' + item.Size + '</div>';
                            odiv += '<span style="margin-left:20px;">' + item.CreateUserName + '</span>';
                            odiv += '<span style="margin-left:20px;">' + new Date(formatDateByJson(item.CreateTime)).Format("yyyy-MM-dd") + '</span>';
                            odiv += '<input type="hidden" class="hiddenArea" data-group="' + item.Group + '" data-url="' + item.Url + '" data-filename="' + item.Name + '">';
                            odiv += '</li>';
                            $('#' + item.TableColumn).append(odiv);
                        }
                    });
                }
            } else {
                parent.layer.alert(data.Message, { icon: 2 });
            }
        });
        //下载附件
        $("body").on("click", ".downloadFile", function () {
            var group = $(this).parent().find(".hiddenArea").data("group");
            var path = $(this).parent().find(".hiddenArea").data("url");
            var fileName = $(this).parent().find(".hiddenArea").data("filename");
            window.location.href = "/Download/DownLoadHB?group=" + group + "&path=" + path + "&fileName=" + fileName;
        });
        //上一步,下一步
        $('.button-group').on('click', ".btnNext", function () {
            var type = $("#Type").val();
            if (type == "1") {
                $(this).parents(".viewTab").hide();
                $(this).parents(".viewTab").next(".viewTab").show();
            } else {
                $(this).parents(".viewTab").hide();
                $(this).parents(".viewTab").next().next(".viewTab").show();
            }

        })
        $('.button-group').on('click', ".btnPrev", function () {
            var type = $("#Type").val();
            if (type == "1") {
                $(this).parents(".viewTab").hide();
                $(this).parents(".viewTab").prev(".viewTab").show();
            } else {
                $(this).parents(".viewTab").hide();
                $(this).parents(".viewTab").prev().prev(".viewTab").show();
            }
        })
        //审核确认
        $(".ApprSuccess").click(function () {
            var id = $("#Id").val();
            layer.prompt({ formType: 2, value: '', title: '请输入审核通过理由' }, function (value, index, elem) {
                $.post("/CompletionAcceptance/Audit?id=" + id, function (result) {
                    if (result.Flag) {
                        layer.msg("操作成功", { time: 1000, icon: 1 }, function () {
                            window.location.href = "/CompletionAcceptance/Index";
                        });
                    } else {
                        layer.alert(result.Message, { icon: 2 });
                    }
                })
            });
        });

        //驳回
        $(".ApprFailure").click(function () {
            var id = $("#Id").val();
            parent.layer.prompt({
                formType: 2,
                title: '请输入驳回理由',
                yes: function (index, layero) {
                    // 获取文本框输入的值
                    var value = layero.find(".layui-layer-input").val();
                    if (value) {
                        $.post("/CompletionAcceptance/Reject?id=" + id, function (data) {
                            if (data.Flag) {
                                parent.layer.msg("操作成功", { time: 2000, icon: 1 });
                                location.href = "/CompletionAcceptance/Index";
                            } else {
                                parent.layer.alert(data.Message, { icon: 2 });
                            }
                        }, "json");
                    } else {
                        parent.layer.alert("请输入驳回理由！", { icon: 2 });
                    }
                }
            });
        });
        //沟通
        $('.exchange').on('click', function () {
            var projectId = $("#ProjectId").val();
            window.location.href = "/Question/Add?businType=Completed&projectId=" + projectId;
        });
    });
</script>
}